package cn.wolfcode.trip.core.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Setter
@Getter
public class Travel extends BaseDomain{

    public static final int STATE_REJECT = -1; // 拒绝
    public static final int STATE_COMON = 0; // 草稿
    public static final int STATE_WAIT = 1; // 待审核
    public static final int STATE_RELEASE = 2; // 已发布


    private String title; // 标题

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date travelTime; // 旅游时间

    private String perExpends; // 人均消费

    private Integer days; // 出行天数

    private Integer person; // 和谁旅游

    private User author; // 作者

    private Date createTime; // 创建时间

    private Date releaseTime; // 发布时间

    private Boolean isPublic = false; // 是否公开

    private Region place; // 旅游地区

    private String coverUrl; // 封面

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date lastUpdateTime; // 最后更新时间

    private Integer state = STATE_COMON; // 状态

    private TravelContent travelContent; // 文章内容

    public String getStateName(){
        String temp = "草稿";
        if(STATE_REJECT==state){
            temp = "拒绝";
        }else if(STATE_WAIT==state){
            temp = "待审核";
        }else if(STATE_RELEASE==state){
            temp = "已发布";
        }
        return temp;
    }
}